import dashboard from '../../../views/dashboard/index.vue'
export default {
    name: "app",
    data() {
        return {
            imgLink: 'https://gitee.com/zhu-wang/cloud-library/blob/master/static/pic/1655815025792_10f037e5-40cd-4dae-aabd-17239b9aca64.png',
            // 左侧菜单栏是否折叠
            isCollapse: true,
            // 被激活的链接地址
            activePath3: "chart",
            userName: ''
        };
    },
    components: {
        dashboard,
    },
    computed: {
        _avatar() {
            // return this.$store.state.current.imageUrl
            return 'https://gitee.com/zhu-wang/cloud-library/blob/master/static/pic/1655815025792_10f037e5-40cd-4dae-aabd-17239b9aca64.png'
        }
    },
    methods: {
        logout() {
            window.sessionStorage.clear();
            this.$router.push("/login_register");
        },
        open() {
            this.isCollapse = false;
            window.sessionStorage.setItem("isCollapse", "");
        },
        close() {
            this.isCollapse = true;
            window.sessionStorage.setItem("isCollapse", this.isCollapse);
        },

        // 保存链接激活状态
        saveFirstNavState() {
            if (window.sessionStorage.getItem("activePath3") == null) {
                window.sessionStorage.setItem("activePath3", "chart");
            }
        },
        saveNavState(activePath3) {
            window.sessionStorage.setItem("activePath3", activePath3);
            this.activePath3 = activePath3;
        },

        // 添加点击事件，记录最新一次点击操作的时间
        updateLastTime() {
            this.$store.commit('login/SET_LASTTIME', new Date().getTime());
        },
    },
    created() {
        this.saveFirstNavState();
        this.isCollapse = (Boolean)(window.sessionStorage.getItem("isCollapse"));
        this.activePath3 = window.sessionStorage.getItem("activePath3");
        if (window.sessionStorage.getItem("token") != null) {
            // this.getUser();
            // 获取用户信息
            this.$store.dispatch('get_current')
            // this.get_current()
        }
    },
}